package com.zmytest.dto;

import lombok.Data;

/**
 * Created on 2018/12/19.
 *
 * @author zhangmingyu
 */
@Data
public class ResponseDto<T> {

    private boolean success;

    private String message;

    private T data;

    private ResponseDto(){}

    public static<T> ResponseDto<T> success(T data){
        ResponseDto<T> responseDto = new ResponseDto<T>();
        responseDto.setSuccess(true);
        responseDto.setData(data);
        return responseDto;
    }

    public static<T> ResponseDto<T> success(String message, T data){
        ResponseDto<T> responseDto = new ResponseDto<T>();
        responseDto.setSuccess(true);
        responseDto.setMessage(message);
        responseDto.setData(data);
        return responseDto;
    }

    public static<T> ResponseDto<T> fail(String message){
        ResponseDto<T> responseDto = new ResponseDto<T>();
        responseDto.setSuccess(false);
        responseDto.setMessage(message);
        return responseDto;
    }

    public static<T> ResponseDto<T> fail(String message,T data){
        ResponseDto<T> responseDto = new ResponseDto<T>();
        responseDto.setSuccess(false);
        responseDto.setMessage(message);
        responseDto.setData(data);
        return responseDto;
    }

}
